<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>管理后台</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>
		<script src="js/config.js" type="application/javascript"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	</head>

	<body>
		<div class="x-body">
			<form class="layui-form" lay-filter="apiinfo">
				<div class="layui-form-item">
					<label class="layui-form-label">模型名称</label>
					<div class="layui-input-block">
						<input type="text" name="modelname" required lay-verify="required" placeholder="请输入用例标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">模型描述</label>
					<div class="layui-input-block">
						<textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>

			</form>
		</div>
		<script>
			layui.use(['form', 'layer'], function() {
				var form = layui.form;
				var layer = layui.layer;
				
				//监听提交
				form.on('submit(formDemo)', function(data) {
					$.ajax({
						url: base_url + '/testcase/model/add',
						type: 'post',
						contentType: 'application/json; charset=utf-8',
						data: JSON.stringify(data.field),
						dataType: 'json',
						async: false,
						success: function(result) {
							if(result.code == '0') {
								layer.msg('保存成功');
								var index = parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							} else {
								layer.msg(result.msg);
							}
						}
					});
					return false;
				});
			});
		</script>
	</body>

</html>